package com.github.cyf.interceptor.page;

/**
 * @author chenyifan
 * @create 2024-04-13 18:23
 */
public class PageHelper {

    private static final ThreadLocal<Page> LOCAL_PAGE = new ThreadLocal<>();

    public static void startPage(int pageNo, int pageSize) {
        if (pageNo <= 0) {
            pageNo = 1;
        }
        if (pageSize <= 0) {
            pageSize = 10;
        }
        LOCAL_PAGE.set(new Page(pageNo, pageSize));
    }

    public static Page getLocalPage() {
        return LOCAL_PAGE.get();
    }

    public static void clearLocalPage() {
        LOCAL_PAGE.remove();
    }

}
